def input(text):
    return raw_input(text + " ").lower()

def yes_no(text):
    result = input(text)[0]
    if result in ["y", "n"]:
        return result == "y"
    else:
        print "Invalid choice."
        return yes_no(text)

def decision(text, choices):
    result = input(text)
    try:
        return choices[result]
    except KeyError:
        print "Invalid choice."
        return decision(text, choices)
